package myapp.com.myapplication;

import android.os.Bundle;

import com.xm.httpapi.BaseUtils.Toast;
import com.xm.httpapi.BaseView.BaseMVPActivity;
import butterknife.ButterKnife;
import butterknife.OnClick;
import myapp.com.myapplication.Model.LoginResult;
import myapp.com.myapplication.Model.PwdLoginRequest;
import myapp.com.myapplication.P.RequestPresenter;


public class RequestMvpActivity extends BaseMVPActivity<RequestPresenter, BaseMVPActivity> implements IRequest.IView {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_requrst;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ButterKnife.bind(this);
    }

    @Override
    protected String showTitle() {
        return "MVP请求";
    }

    @Override
    public void setData(LoginResult loginResult) {

    }

    //不需要处理就不需要定义这个
    @Override
    public void err(String err) {
        // 这里处理错误拿toast举例子
        Toast.show(err);
    }

    @OnClick(R.id.btn_nohandle_err)
    void nohandleErr() {
        PwdLoginRequest pwdLoginRequest = new PwdLoginRequest("13712345678", "yf123456");
        //第二个参数是为了举例子，实际中不需要
        presenter.load(pwdLoginRequest, false);
    }

    @OnClick(R.id.btn_handle_err)
    void handleErr() {
        PwdLoginRequest pwdLoginRequest = new PwdLoginRequest("13712345678", "yf123456");
        //第二个参数是为了举例子，实际中不需要
        presenter.load(pwdLoginRequest, true);
    }
    //其他用法以后再说
}
